namespace CSharpPro._1016;

public class Demo
{
  
  public void Demo1()
  {
    Console.WriteLine("请输入三个整数：");
   
    string input = Console.ReadLine();
    string[] numberStrings = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    int[] numbers = new int[3];
    for (int i = 0; i < 3; i++)
    {
      numbers[i] = int.Parse(numberStrings[i]);
    }
    Array.Sort(numbers);
    Console.WriteLine("从小到大排序后的结果为：");
    Console.WriteLine($"{numbers[0]} {numbers[1]} {numbers[2]}");
  }

  
  public void Demo2()
  {
    int num = 0;
    for (int i = 1; i <= 100; i++)
    {
      if (i % 7 != 0)
      {
        
        int x, y;
        x = i % 10;
        y = (i-x) / 10;
        if (x != 7 && y != 7)
        {
          num=num+i;
          Console.WriteLine(i+" ");
        }
      }
    }
    Console.WriteLine("总和为："+num);
  }

  
  public void Demo3()
  {
    Console.WriteLine("9*9乘法表：");
    for (int i = 1; i <= 9; i++)
    {
      for (int j = 1; j <= i; j++)
      {
        Console.Write(i+"*"+j+"="+i*j+" ");
    
      }
      Console.Write("\n");
      
      
    }
  }

  
  public void Demo4()
  {
    for (int i = 2; i <= 1000; i++)
    {
      int count = i;
      int sum = 0;
      for (int j = 1; j <= i / 2; j++)
      {
        if (i % j == 0)
        {
          sum=sum+j;
        }
        
      }

      if (sum == i)
      {
        Console.WriteLine(i);
      }
    }
  }

  
  public void Demo5()
  {
    int count=0;
    Console.WriteLine("请输入一个整数：");
    int num = Convert.ToInt32(Console.ReadLine());
    while (num != 0)
    {
      
      
      int x = num % 10;
      Console.Write(x);
      num = num / 10;
      count++;
    }
    Console.WriteLine();
    Console.WriteLine(count);
  }

  
  public void Demo6()
  {
    int num = Convert.ToInt32(Console.ReadLine());
    int center = (num + 1) / 2; // 计算菱形中心行位置
        
    // 打印上半部分（包括中心行）
    for (int i = 1; i <= center; i++)
    {
      // 打印空格
      for (int j = center; j > i; j--)
      {
        Console.Write(" ");
      }
            
      // 打印星号
      for (int k = 1; k <= 2 * i - 1; k++)
      {
        Console.Write("*");
      }
        
      Console.WriteLine(); // 换行
    }
        
    // 打印下半部分（不包括中心行）
    for (int i = center - 1; i >= 1; i--)
    {
      // 打印空格
      for (int j = center; j > i; j--)
      {
        Console.Write(" ");
      }
            
      // 打印星号
      for (int k = 1; k <= 2 * i - 1; k++)
      {
        Console.Write("*");
      }
            
      Console.WriteLine(); // 换行
    }
    
    
    
    
  }
  
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}